<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>发现</title>
<link rel="stylesheet" href="${ctxPath}/layui/css/layui.css">
<style>
td,th{
	padding: 10px;
}
.gray { 
    -webkit-filter: grayscale(100%);
    -moz-filter: grayscale(100%);
    -ms-filter: grayscale(100%);
    -o-filter: grayscale(100%);
    filter: grayscale(100%);
    filter: gray;
}
</style>
</head>
<body>
	<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
		<ul class="layui-tab-title">
			<li class="layui-this">好友管理</li>
			<li>群组管理</li>
			<li>找人</li>
			<li>找群</li>
			<li>建群</li>
		</ul>
		<div class="layui-tab-content">
			<div class="layui-tab-item layui-show">
				<div id="showFriend_view" style="padding: 0px"></div>
			</div>
			<div class="layui-tab-item ">
				<div id="showGroup_view" style="padding: 0px;float:left;width:25%"></div>
				<div id="showGroupMember_view" style="padding-left: 10px;float:left;width:70%"></div>
			</div>
			<div class="layui-tab-item ">
				<table>
					<tr>
						<td style="width: 85%"><input type="text" id="uid" required
							lay-verify="required" placeholder="请输入 账号/用户名" autocomplete="off"
							class="layui-input"></td>
						<td style="width: 10%"><button id="searchUser"
								class="layui-btn layui-btn-normal">查找</button></td>
					</tr>
				</table>
				<div id="findUser_view" style="padding-left: 20px"></div>
				<div id="findUser_page" style="margin: 0 10px;"></div>
			</div>
			<div class="layui-tab-item">
					<table>
						<tr>
							<td style="width: 85%"><input type="text"  id="gid"
								required lay-verify="required" placeholder="请输入群号/群名"
								autocomplete="off" class="layui-input"></td>
							<td style="width: 10%"><button id="searchGroup"
									class="layui-btn layui-btn-normal">查找</button></td>
						</tr>
					</table>
					<div id="findGroup_view" style="padding-left: 20px"></div>
					<div id="findGroup_page" style="margin: 0 10px;"></div>
			</div>
			<div class="layui-tab-item">
				<button class="layui-btn layui-btn-normal" onclick="addGroup()">建群</button><br/><br/>	
			</div>
		</div>
	</div>
	<br />

	<textarea title="群列表" id="showGroup_tpl" style="display: none;">
		<ul class="layui-tree" style="float:left;width:100%;">
		{{# for(var i = 0, len = d.length; i < len; i++){ }}
           <li class="site-tree-noicon " style="height:50px;">
    		  <a href="#" onclick="showGroupMember(${session.USERINFO.id},{{d[i].id}})">
    		  <span style="font-size:18px;">
    		  <img src="{{d[i].avatar}}" class="layui-circle" style="vertical-align: middle;" height="40px" width="40px" />
      		  &nbsp;&nbsp;{{d[i].name}}({{d[i].id}})</span>
     		  </a>
           </li>
		{{# } }}
		</ul>
	</textarea>
	

	
	<textarea title="好友列表" id="showFriend_tpl" style="display: none;">
		<button class="layui-btn layui-btn-normal" onclick="addTeam()">增加分组</button><br/><br/>
		<div class="layui-collapse " >
		{{# for(var i = 0, len = d.length; i < len; i++){ }}
			  <div class="layui-colla-item">
			    <h2 class="layui-colla-title">分组({{d[i].team.name}})</h2>
			    <div class="layui-colla-content layui-show">
			    <a href="#" onclick="delTeam({{d[i].team.no}})">删除分组</a><br/><br/>
			   <table>
				{{# if(d[i].users.length==0){  }}
					该分组下无好友
				{{#  }else{  }}
				{{# for(var j = 0,len2 =d[i].users.length; j<len2;j++){  }}
				<tr>
					<td ><img src="{{d[i].users[j].avatar}}" 
					{{# if(d[i].users[j].status=='online') { }}
					class="layui-circle"
					{{#  }else{  }}
					class="gray layui-circle" 
					{{#  }  }}	
					width="30px" height="30px"/></td>
					<td style="width:200px"><a href="#" onclick="showUserInfo({{d[i].users[j].id}})">{{d[i].users[j].username}}({{d[i].users[j].id}})</a></td>
					<td >	
						{{# if(d[i].users[j].status=='online') { }}
							在线
						{{#  }else{  }}
							离线
						{{#  }  }}	
					</td>
					<td><a href="#" onclick="moveFriend(${userInfo.id},{{d[i].users[j].id}})">移动好友</a></td>
					<td><a href="#" onclick="delFriend(${userInfo.id},{{d[i].users[j].id}})" >删除</a></td>
				</tr>	
			{{# } }}
			{{# } }}
					</table>
				</div>
			  </div>
		{{# } }}
		</div>
	</textarea>
	
	<textarea title="寻找用户" id="findUser_tpl" style="display: none;">
		{{# if(d.data.length==0){ }}
			<br>
			<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;暂无搜索结果</p>
		{{# }else{ }}
			<table width="100%">
				<thead>
					<td>头像</td>
					<td>账号</td>
					<td>昵称</td>
					<td>状态</td>
					<td>操作</td>
				</thead>
				{{# for(var i = 0, len = d.data.length; i < len; i++){   }}
					<tr>
						<td><img src="{{d.data[i].avatar}}" class="layui-circle" width="30px"height="30px" /></td>
						<td><a href="#" onclick="showUserInfo({{d.data[i].id}})">{{d.data[i].id}}</a></td>
						<td>{{d.data[i].username}}</td>
						<td>
							{{# if(d.data[i].status=='online') { }}
								在线
							{{#  }else{  }}
								离线
							{{#  }  }}	
						</td>
						<td>
							{{# if(d.data[i].isFriend==1) { }}
								已经是好友,无需添加
							{{#  }else{  }}
								<button class="layui-btn layui-btn-normal" onclick="applyAddFriend('{{d.data[i].username}}','{{d.data[i].avatar}}','{{d.data[i].id}}')">加为好友</button>
							{{#  }  }}	
						</td>
					</tr>
				 {{# }  }}
			 </table>	 
		{{# } }}
	</textarea>


	<textarea title="寻找群组" id="findGroup_tpl" style="display: none; ">
		{{# if(d.data.length==0){ }}
			<br><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;暂无搜索结果</p>
		{{# }else{ }}
			<table width="100%">
				<thead>
					<td>头像</td>
					<td>群号</td>
					<td>群名</td>
					<td>操作</td>
				</thead>
				{{# for(var i = 0, len = d.data.length; i < len; i++){   }}
					<tr>
						<td><img src="{{d.data[i].avatar}}" class="layui-circle" width="30px"height="30px" /></td>
						<td><a href="#" onclick="showUserInfo({{d.data[i].id}})">{{d.data[i].id}}</a></td>
						<td>{{d.data[i].name}}</td>
						<td>
							{{# if(d.data[i].alreadyAdd==1) { }}
								您已经加入该群,无需添加
							{{#  }else{  }}
								<button class="layui-btn layui-btn-normal" onclick="applyAddGroup('{{d.data[i].name}}','{{d.data[i].avatar}}','{{d.data[i].id}}')">申请入群</button>
							{{#  }  }}	
						</td>
					</tr>
				 {{# }  }}
			 </table>
		 {{# } }}
	</textarea>

	<script id="showGroupMember_tpl" type="text/html">
		<span >
  			群管理&nbsp;&nbsp;>&nbsp;
 			显示群成员
		</span>
		<p>您的身份是
			{{# if(d.type=='0') {  }}
				群主  <a href="#" onclick="inviteFriend({{d.gid}})">[邀请好友]</a>|<a href="#" onclick="showGroupMsgbox({{d.gid}})">[群消息盒子]</a>|<a href="#" onclick="delGroup({{d.gid}})">[解散该群]</a>
			{{# }else if(d.type=='1'){ }}
				管理员 <a href="#" onclick="inviteFriend({{d.gid}})">[邀请好友]</a>|<a href="#" onclick="showGroupMsgbox({{d.gid}})">[群消息盒子]</a>|<a href="#" onclick="quitGroup(${session.USERINFO.id},{{d.gid}})">[退出该群]</a>
			{{# }else{ }}
				群成员<a href="#" onclick="quitGroup(${userInfo.id},{{d.gid}})">[退出该群]</a>
			{{# } }}
		</p>
		<table style="width:100%" class="layui-table">
		<thead>
		<th>成员</th>
		<th>状态</th>
		<th>身份</th>
		{{# if(d.type=='0') {  }}
		<th>权限管理</th>
		{{# } }}
		{{# if(d.type=='0'||d.type=='1') {  }}
		<th>操作</th>
		{{# } }}
		</thead>
		{{# for(var i = 0, len = d.members.length; i < len; i++){ }}
				<tr>
					<td ><a href="#" onclick="showUserInfo({{d.members[i].id}})"><img src="{{d.members[i].avatar}}" 
					{{# if(d.members[i].status=='online') { }}
					class="layui-circle" 
					{{#  }else{  }}
					class="gray layui-circle" 
					{{#  }  }}	
					width="50px" height="50px"/>&nbsp;&nbsp;&nbsp;&nbsp;{{d.members[i].username}}({{d.members[i].id}})</a></td>
					<td>
						{{# if(d.members[i].status=='online') { }}
							在线
						{{#  }else{  }}
							离线
						{{#  }  }}	
					</td>
					<td>
						{{# if(d.members[i].type=='0') {  }}
							群主  
						{{# }else if(d.members[i].type=='1'){ }}
							管理员
						{{# }else{ }}
							群成员
						{{# } }}
					</td>
					{{# if(d.type=='0') { }}
						{{#	if(d.members[i].type=='0'){  }}
							<td>/</td>
						{{#	}else if(d.members[i].type=='1'){  }}
							<td><a href="#" onclick="updateMember({{d.members[i].id}},{{d.gid}},'2')">解除管理员</a></td>
						{{# }else{  }}
							<td><a href="#" onclick="updateMember({{d.members[i].id}},{{d.gid}},'1')">任命管理员</a></td>
						{{# }  }}
					{{# } }}
					{{# if(d.type=='0') {  }}
						{{#  if(d.members[i].type=='0'){   }}
							<td>
							/
							</td>
						{{#  }else{  }}
							<td>
							<a href="#" onclick="delMember({{d.members[i].id}},{{d.gid}})">踢出该群</a>
							</td>
						{{#  } }} 
					{{# }else if(d.type=='1'){  }}
						{{#  if(d.members[i].type!='2'){   }}
							<td>
							/
							</td>
						{{#  }else{  }}
							<td>
							<a href="#" onclick="delMember({{d.members[i].id}},{{d.gid}})">踢出该群</a>
							</td>
						{{#  } 	}}
					{{# }  }}		
				</tr>	
		{{# } }}	
		</table>
	</script>

	<script id="showTeamList" type="text/html">
		<form class="layui-form" >
  			<div class="layui-form-item">
				<div class="layui-inline">
   			 		<div class="layui-input-inline" style="width: 200px;">
						<select name="tno" id="move_tno" lay-verify="">
						<option value="">请选择分组</option>
						{{# for(var i = 0, len = d.length; i < len; i++){ }}
 						<option value="{{d[i].no}}">{{d[i].name}}</option>
						{{# } }}
					</select>   
					</div> 
				</div>
				</div>
			</form>
	</script>
	
	<script id="showInviteList" type="text/html">
		{{# if(d.length==0){ }}
			<br>
			<p>没有可邀请的好友</p>
		{{# }else{ }}
			<table width="100%" >
				{{# for(var i = 0, len = d.length; i < len; i++){   }}
					<tr>
						<td><input type="checkbox" id="invite_friend_checkbox" value="{{d[i].id}}" /> </td>
						<td><img src="{{d[i].avatar}}" class="layui-circle" width="30px"height="30px" /></td>
						<td>{{d[i].username}}({{d[i].id}})</td>				
					</tr>
				 {{# }  }}
			 </table>	 
		{{# } }}
	</script>
	<script src="${ctxPath}/resources/js/jquery-2.2.4.min.js"></script>
	<script src="${ctxPath}/layui/layui.js"></script>
	<script>
		layui.use([ 'layim', 'laypage','form','laytpl','element' ],
			function() {
				var layim = layui.layim,form = layui.form(),element = layui.element(),layer = layui.layer, laytpl = layui.laytpl, $ = layui.jquery, laypage = layui.laypage;
				//一些添加好友请求之类的交互参见文档
				//显示好友列表
				showFriend(element);
				//显示群组列表
				showGroup();
				//搜索用户按钮初始化
				$('#searchUser').on('click',function(){
					var uid = $('#uid').val();
					if(uid ==''){
						layer.open({
							  title: '错误'
							  ,content: '请输入正确id'
							});     		  
					}else{		
						findUser(1);
					}
				});
				$('#searchGroup').on('click',function(){
					var gid = $('#gid').val();
					if(gid ==''){
						layer.open({
							  title: '错误'
							  ,content: '不能输入空串'
							});     		  
					}else{		
						findGroup(1);
					}
				});
		});
		//注意：选项卡 依赖 element 模块，否则无法进行功能性操作
		
		function showFriend(element){
			$.ajax({
				type: "POST",
				url:'${ctxPath}/user/showFriend',
				data:{
					id:${userInfo.id}
				},	
				anysc:true,
				success:function(res){
					var html = layui.laytpl(showFriend_tpl.value).render(res);
					$('#showFriend_view').html(html);
					element.init();
					//此处仅仅是为了演示变化的内容
				}
			});	
		}
		
		
		
		
		function showGroup(){
			$.ajax({
				type: "POST",
				url:'${ctxPath}/group/showGroup',
				data:{
					id:${userInfo.id}
				},	
				anysc:true,
				success:function(res){
					var html = layui.laytpl(showGroup_tpl.value).render(res);
					$('#showGroup_view').html(html);
					//此处仅仅是为了演示变化的内容
				}
			});	
		}
		function findGroup(curr){
			$.ajax({
				type: "POST",
				url:'${ctxPath}/group/search',
				data:{
					page : curr || 1,
					condition:$('#gid').val(),
					id:${userInfo.id}
				},	
				anysc:true,
				success:function(res){
					var html = layui.laytpl(findGroup_tpl.value).render(res);
					$('#findGroup_view').html(html);
					//此处仅仅是为了演示变化的内容
					layui.laypage({
						cont : 'findGroup_page', //容器。值支持id名、原生dom对象，jquery对象。
						pages : res.pages, //通过后台拿到的总页数
						curr : curr || 1, //当前页
						jump : function(obj, first) { //触发分页后的回调
							if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
								demo(obj.curr);
							}
						}
					});
				}
			});	
		};
		function findUser(curr){
			$.ajax({
				type: "POST",
				url:'${ctxPath}/user/search',
				data:{
					page : curr || 1,
					condition:$('#uid').val(),
					id:${userInfo.id}
				},	
				anysc:true,
				success:function(res){
					var html = layui.laytpl(findUser_tpl.value).render(res);
					$('#findUser_view').html(html);
					//此处仅仅是为了演示变化的内容
					layui.laypage({
						cont : 'findUser_page', //容器。值支持id名、原生dom对象，jquery对象。
						pages : res.pages, //通过后台拿到的总页数
						curr : curr || 1, //当前页
						jump : function(obj, first) { //触发分页后的回调
							if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
								demo(obj.curr);
							}
						}
					});
				}
			});	
		};
		
		function moveFriend(id,fid){
			$.ajax({
				type: "POST",
				url:'${ctxPath}/team/showTeamExcludeFriendId',
				data:{
					id:id,
					friendId:fid
				},	
				anysc:true,
				success:function(res){
					var tpl = $('#showTeamList').text(); //读取模版
					var render = layui.laytpl(tpl).render(res);
					console.log(render);
					layer.open({
						  title: '移动好友至'
						  ,content: render
						  ,area: ['300px', '400px']
						  , btn: ['修改','取消']
						  ,yes: function(index, layero){
							  if($('#move_tno').val()==''){
								  layer.close(index); 
								  layer.open({
									  title: '通知'
									  ,content: '分组不能为空'
									});       
							  }else{
								  $.ajax({
								        url : '${ctxPath}/friend/moveFriend',
								        data:{id:id,
								        	friendId:fid,
								        	tno:$('#move_tno').val(),  	
								        },
								        async : false,
								        type : "POST",
								        success : function (res){
								        	//移动好友分组,先删除再添加
								        	parent.layui.layim.removeList({
								        		  type: 'friend' //或者group
								        		  ,id: fid //好友或者群组ID
								        		});
								        	parent.layui.layim.addList(res);
								        	parent.layui.layim.setFriendStatus(res.id,res.status ); 
								        	layer.close(index); 
								        	location.reload();	
								        }
								    });
							  }
						  }
						  ,btn2: function(index, layero){
							  layer.close(index); 
						  }
						}); 
					layui.form().render();
				}
			});	
		}
		
   		function delFriend(id,fid){
   			layer.confirm('确定要删除好友'+fid+'吗?此操作也会删除对方好友列表中关于你的信息', function(index){
				parent.send('{type:"notifyDelFriend",mine:{"id":"'+id+'"},toFriend:{"id":"'+fid+'"}}');
				layer.close(index); 
				location.reload();	
   			});               
   		}
		

		
		function showGroupMember(id,gid){
   			$.ajax({
				type: "POST",
				url:'${ctxPath}/group/showGroupMember',
				data:{
					id:id,
					groupId:gid
				},	
				anysc:true,
				success:function(res){
					var tpl = $('#showGroupMember_tpl').text(); //读取模版
					var render = layui.laytpl(tpl).render(res);
					$('#showGroupMember_view').html(render);
				}});
   			layui.element().init();
   		}
		
		function showUserInfo(id){
			parent.showUserInfo(id);
		}
		
		function applyAddFriend(username,avatar,friendId){
			parent.layui.layim.add({
				  type: 'friend' //friend：申请加好友、group：申请加群
				  ,username: username //好友昵称，若申请加群，参数为：groupname
				  ,avatar: avatar //头像
				  ,submit: function(group, remark, index){ //一般在此执行Ajax和WS，以通知对方
					parent.layer.close(index); //关闭改面板
				    $.post('${ctxPath}/notify/apply', {
			        	fromUid: ${userInfo.id}, //对方用户ID
			        	uid:friendId,
			        	fromGroup:group,
			        	remark:remark
			        }, function(res){
 			        	 if(res=='success'){
 			        		parent.layer.open({
 			        			  title: '提示'
 			        			  ,content: '申请已经提交,请等待对方答复'
 			        			});     
			        	 }else if(res='repeat'){
			        		 parent.layer.open({
			        			  title: '提示'
			        			  ,content: '您已经申请过了,请耐心等待'
			        			});     
 			        	 }else{
 			        		parent.layer.open({
			        			  title: '提示'
			        			  ,content: '发生未知错误,请重试'
			        			});   
 			        	 }
			        });
				  }
				});
		}
		
		function applyAddGroup(groupname,avatar,gid){
			parent.layui.layim.add({
				  type: 'group' //friend：申请加好友、group：申请加群
				  ,groupname: groupname //好友昵称，若申请加群，参数为：groupname
				  ,avatar: avatar //头像
				  ,submit: function(group, remark, index){ //一般在此执行Ajax和WS，以通知对方
					parent.layer.close(index); //关闭改面板
				    $.post('${ctxPath}/notifygroup/apply', {
			        	fromUid: ${userInfo.id}, //对方用户ID
			        	gid:gid,
			        	fromGroup:group,
			        	remark:remark
			        }, function(res){
 			        	 if(res=='success'){
 			        		parent.layer.open({
 			        			  title: '提示'
 			        			  ,content: '申请已经提交,请等待对方答复'
 			        			});     
			        	 }else if(res=="repeat"){
			        		 parent.layer.open({
			        			  title: '提示'
			        			  ,content: '您已经申请过了,请耐心等待'
			        			});     
 			        	 }else{
 			        		 parent.layer.open({
			        			  title: '提示'
			        			  ,content: '发生未知错误,请重试'
			        			});  
 			        	 }
			        });
				  }
				});
		}
		
		function showGroupMsgbox(gid){
			parent.layer.open({
				  type: 2, 
				  content: '${ctxPath}/direct/directGroupMsgbox?gid='+gid, //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
					area: ['700px', '450px'],
					title: '群消息盒子'
			 }); 	
		}

		function quitGroup(uid,gid){
			parent.layer.confirm('确定退出该群吗', function(index){
				 $.post('${ctxPath}/group/quitGroup', {
					 	uid: uid, 
			        	gid:gid
			        }, function(res){
			        	parent.layer.close(index);
				        parent.send('{type:"notifyDelMember",mine:{"id":"'+uid+'"},toGroup:{"id":"'+gid+'"}}');	
				        location.reload();
			        });
			});
		}
		function delMember(uid,gid){
			 parent.layer.confirm('确定将'+uid+'踢出该群吗', function(index){
				 $.post('${ctxPath}/group/delMember', {
					 	uid: uid, //对方用户ID
			        	gid:gid
			        }, function(res){
			        	parent.layer.close(index);
				        parent.send('{type:"notifyDelMember",mine:{"id":"'+uid+'"},toGroup:{"id":"'+gid+'"}}');	
				        location.reload();
			        });
			 });
		}
		
		function delGroup(gid){
			parent.layer.confirm('确定解散该群吗', function(index){
			        	parent.layer.close(index);
				        parent.send('{type:"notifyDelGroup",mine:{"id":"'+gid+'"},toGroup:{"id":"'+gid+'"}}');	
				        location.reload();
			 });
		}
		
		function addTeam(){
			parent.layer.prompt({title: '请输入分组名称'},function(value, index, elem){
				  $.post('${ctxPath}/team/addTeam', {
						id:${userInfo.id},
						name:value
			        }, function(res){
			        	  location.reload();
						  parent.layer.close(index);
			        });
				}); 
		}
		
		function addGroup(){
			parent.layer.prompt({title: '请输入群名称', maxlength:20},function(value, index, elem){
				  $.post('${ctxPath}/group/addGroup', {
						uid:${userInfo.id},
						name:value
			        }, function(res){
			        	parent.layer.close(index);
			        	if(res=='fail'){
			        		parent.layer.open({
			        			  title: '提示'
			        			  ,content: '创建群组失败,原因未知'
			        			});     		        			  
			        	}else{
			        		parent.layer.open({
			        			  title: '提示'
			        			  ,content: '创建群组'+value+'成功,群号:'+res
			        			  ,success:function(){
			        				  location.reload();
									  parent.layer.close(index);
			        			  }
			        			});     	    		  	
			        	}  
			        });
				}); 
		}
		
		function delTeam(tno){
			parent.layer.confirm('是否删除分组,该分组下的好友会被移动到临时分组', {icon: 3, title:'提示'}, function(index){
				  //do something
				  	 $.post('${ctxPath}/team/delTeam', {
				  		uid:${session.USERINFO.id},
						no:tno
			        }, function(res){
			        	  location.reload();
						  parent.layer.close(index);
			        });
				});
		}
		
		function updateMember(uid,gid,type){
			if(type=='0'){
				 parent.layer.confirm('确定解除其管理员权限吗？', function(index){
					 $.post('${ctxPath}/group/updateGroupMember', {
							 uid:uid, //对方用户ID
				        	gid:gid,
				        	type:type,
				        }, function(res){
				        	parent.layer.close(index);
				        	showGroupMember('${userInfo.id}',gid);
				        });
				 });
			}else{
				 parent.layer.confirm('确定任命为管理员吗？', function(index){
					 $.post('${ctxPath}/group/updateGroupMember', {
							 uid:uid, //对方用户ID
				        	gid:gid,
				        	type:type,
				        }, function(res){
				        	parent.layer.close(index);
				        	showGroupMember('${userInfo.id}',gid);
				        });
				 });
			}
		}
		
		function inviteFriend(gid){
			$.ajax({
				type: "POST",
				url:'${ctxPath}/friend/inviteFriendList',
				data:{
					uid:${session.USERINFO.id},
					gid:gid
				},	
				anysc:true,
				success:function(res){
					var tpl = $('#showInviteList').text(); //读取模版
					var render = layui.laytpl(tpl).render(res);
					layer.open({
						  title: '邀请好友'
						  ,content: render
						  ,area: ['300px', '400px']
						  , btn: ['邀请','取消']
						  ,yes: function(index, layero){ 
							  var selected = false;
							  $("#invite_friend_checkbox ").each(function(){   
								if ($(this).attr('checked') ==false) {
						                
						        }else{
						        	selected = true;
									  var val = $(this).val();  
									  $.ajax({
										type: "POST",
										url:'${ctxPath}/friend/inviteFriend',
										data:{
											uid:val,
											gid:gid
										},	
										anysc:false,
										success:function(res){
													
										}
									  });
						        } 
							  });  
							  
							  if(selected==true){
								  layer.close(index); 
								  parent.layer.open({title:'提示',content:"邀请好友成功，请等待回应"});
							  }else{
								  layer.close(index);
								  parent.layer.open({title:'提示',content:"请选择好友"});
							  }
						  }
						  ,btn2: function(index, layero){
							  layer.close(index); 
						  }
						}); 
				}
			});
		}
		
	</script>
</body>
</html>
